editing an agent returns you to correct scenario or index

Andrew Cantino 9 years ago
parent
commit
617c3c51c6

+ 6 - 6
app/views/agents/_action_menu.html.erb

@@ -1,7 +1,7 @@
1 1
 <ul class="dropdown-menu" role="menu">
2 2
   <% if agent.can_be_scheduled? %>
3 3
     <li>
4
-      <%= link_to icon_tag('glyphicon-refresh', class: 'color-success') + ' Run', run_agent_path(agent, return: returnTo), method: :post, tabindex: "-1" %>
4
+      <%= link_to icon_tag('glyphicon-refresh', class: 'color-success') + ' Run', run_agent_path(agent, return: return_to), method: :post, tabindex: "-1" %>
5 5
     </li>
6 6
   <% end %>
7 7
 
@@ -18,7 +18,7 @@
18 18
   <li class="divider"></li>
19 19
 
20 20
   <li>
21
-    <%= link_to icon_tag('glyphicon-pencil') + ' Edit agent'.html_safe, edit_agent_path(agent) %>
21
+    <%= link_to icon_tag('glyphicon-pencil') + ' Edit agent'.html_safe, edit_agent_path(agent, return: return_to) %>
22 22
   </li>
23 23
 
24 24
   <li>
@@ -40,7 +40,7 @@
40 40
 
41 41
     <% agent.scenarios.each do |scenario| %>
42 42
       <li>
43
-        <%= link_to icon_tag('glyphicon-remove-circle', class: 'color-warning') + " Remove from #{scenario_label(scenario)}".html_safe, leave_scenario_agent_path(agent, scenario_id: scenario.to_param, return: returnTo), method: :put, tabindex: "-1" %>
43
+        <%= link_to icon_tag('glyphicon-remove-circle', class: 'color-warning') + " Remove from #{scenario_label(scenario)}".html_safe, leave_scenario_agent_path(agent, scenario_id: scenario.to_param, return: return_to), method: :put, tabindex: "-1" %>
44 44
       </li>
45 45
     <% end %>
46 46
   <% end %>
@@ -49,12 +49,12 @@
49 49
 
50 50
   <% if agent.can_create_events? && agent.events.count > 0 %>
51 51
     <li>
52
-      <%= link_to icon_tag('glyphicon-trash', class: 'color-danger') + ' Delete all events', remove_events_agent_path(agent, return: returnTo), method: :delete, data: {confirm: 'Are you sure you want to delete ALL emitted events for this Agent?'}, tabindex: "-1" %>
52
+      <%= link_to icon_tag('glyphicon-trash', class: 'color-danger') + ' Delete all events', remove_events_agent_path(agent, return: return_to), method: :delete, data: {confirm: 'Are you sure you want to delete ALL emitted events for this Agent?'}, tabindex: "-1" %>
53 53
     </li>
54 54
   <% end %>
55 55
 
56 56
   <li>
57
-    <%= link_to icon_tag('glyphicon-remove', class: 'color-danger') + ' Delete agent', agent_path(agent, return: returnTo), method: :delete, data: { confirm: 'Are you sure that you want to permanently delete this Agent?' }, tabindex: "-1" %>
57
+    <%= link_to icon_tag('glyphicon-remove', class: 'color-danger') + ' Delete agent', agent_path(agent, return: return_to), method: :delete, data: { confirm: 'Are you sure that you want to permanently delete this Agent?' }, tabindex: "-1" %>
58 58
   </li>
59 59
 </ul>
60 60
 
@@ -69,7 +69,7 @@
69 69
         <p><% if agent.disabled? %>Enable<% else %>Disable<% end %> &quot;<%= agent.name %>&quot;?</p>
70 70
       </div>
71 71
       <div class="modal-footer">
72
-        <%= form_for(agent, as: :agent, url: agent_path(agent, return: returnTo), method: 'PUT') do |f| %>
72
+        <%= form_for(agent, as: :agent, url: agent_path(agent, return: return_to), method: 'PUT') do |f| %>
73 73
           <% if agent.disabled && agent.can_receive_events? %>
74 74
             <div class="form-group">
75 75
               <%= f.check_box :drop_pending_events %>

+ 2 - 0
app/views/agents/_form.html.erb

@@ -15,6 +15,8 @@
15 15
              method: @agent.new_record? ? "POST" : "PUT",
16 16
              html: { class: 'agent-form' }) do |f| %>
17 17
 
18
+  <%= hidden_field_tag :return, params[:return] %>
19
+
18 20
   <div class="row">
19 21
     <div class="col-md-6">
20 22
       <div class="row">

+ 1 - 1
app/views/agents/_table.html.erb

@@ -64,7 +64,7 @@
64 64
             <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
65 65
               <span class="glyphicon glyphicon-th-list"></span> Actions <span class="caret"></span>
66 66
             </button>
67
-            <%= render 'agents/action_menu', :agent => agent, :returnTo => (defined?(returnTo) && returnTo) || "index" %>
67
+            <%= render 'agents/action_menu', :agent => agent, :return_to => (defined?(return_to) && return_to) || request.path %>
68 68
           </div>
69 69
         </td>
70 70
       </tr>

+ 1 - 1
app/views/agents/show.html.erb

@@ -22,7 +22,7 @@
22 22
 
23 23
           <li class="dropdown">
24 24
             <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-th-list"></span> Actions <span class="caret"></span></a>
25
-            <%= render 'agents/action_menu', :agent => @agent, :returnTo => "show" %>
25
+            <%= render 'agents/action_menu', :agent => @agent, :return_to => "show" %>
26 26
           </li>
27 27
         </ul>
28 28
       </div>

+ 1 - 1
app/views/scenarios/show.html.erb

@@ -10,7 +10,7 @@
10 10
         <blockquote><%= markdown(@scenario.description) %></blockquote>
11 11
       <% end %>
12 12
 
13
-      <%= render 'agents/table', :returnTo => scenario_path(@scenario) %>
13
+      <%= render 'agents/table', :return_to => scenario_path(@scenario) %>
14 14
 
15 15
       <br/>
16 16